require File.dirname(__FILE__)+"/../../../test_helper"
require "starframe/sprite"
require "starframe/sprite/collision"
require "starframe/sprite/collision/dot"

class TestStarFrameSpriteCollisionDot < Test::Unit::TestCase
  class TestSprite < StarFrame::Sprite
    @texture = StarRuby::Texture.load "test"
  end
  def setup
    @sprite1 = TestSprite.new(0, 0)
    @sprite2 = TestSprite.new(0, 0)
  end
  
  def test_collide_dot_dot
    dot1 = StarFrame::Sprite::Collision::Dot.new(@sprite1, nil,  1, -1)
    dot2 = StarFrame::Sprite::Collision::Dot.new(@sprite2, nil, -1,  1)
    
    (-2..2).each do |@sprite2.x|
      (-2..2).each do |@sprite2.y|
        result = (@sprite2.x == 2 && @sprite2.y == -2)
        assert_equal result, dot1.collide?(dot2), "#{@sprite2.x},#{@sprite2.y}"
        assert_equal result, dot2.collide?(dot1), "#{@sprite2.x},#{@sprite2.y}"
      end
    end
  end
end
